{extend name='public/_home' /}

{block name='title'}文章编辑{/block}

{block name='main'}
<!-- Page Content -->
<div class="page-content">
    <!-- Page Breadcrumb -->
    <div class="page-breadcrumbs">
        <ul class="breadcrumb">
            <li>
                <i class="fa fa-home"></i>&nbsp;文章管理
            </li>
            <li>文章编辑</li>
        </ul>
    </div>
    <!-- /Page Breadcrumb -->
    <!-- Page Body -->
    <div class="page-body">
        <div class="row">
            <div class="col-xs-12">
                <div class="widget radius-bordered">
                    <div class="widget-header bordered-bottom bordered-themeprimary">
                        <span class="widget-caption">文章编辑</span>
                    </div>
                    <div class="widget-body">
                        <form action="" class="form-horizontal">

                            <div class="form-group">
                                <label for="title" class="control-label col-sm-2">文章标题</label>
                                <div class="col-sm-6">
                                    <input type="text" class="form-control" id="title" name="title"
                                           value="{$artInfo.title}"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="title" class="control-label col-sm-2">文章标签</label>
                                <div class="col-sm-6">
                                    <input type="text" class="form-control" id="tags" name="tags"
                                           value="{$artInfo.tags}"/>
                                    <span class="help-block">标签以|来分隔</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="checkbox col-sm-offset-2">
                                    <label>
                                        <input type="checkbox" name="is_top" value="1" {$artInfo['is_top'] ?
                                        'checked' : ''}>
                                        <span class="text">是否推进</span>
                                    </label>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="cate_id" class="control-label col-sm-2">所属导航</label>
                                <div class="col-sm-6">
                                    <select id="cate_id" name="cate_id" class="form-control">
                                        <option value="{$artInfo.cate_list.id}">{$artInfo.cate_list.catename}
                                        </option>
                                        {volist name='cates' id='vo'}
                                        <option value="{$vo.id}">{$vo.catename}</option>
                                        {/volist}
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="content" class="control-label col-sm-2">文章概要</label>
                                <div class="col-sm-6">
                                    <textarea name="desc" id="desc" cols="30" rows="5" class="form-control">{$artInfo.desc}</textarea>
                                </div>
                            </div>

                            <div class="form-group">
                                <label for="content" class="control-label col-sm-2">文章内容</label>
                                <div class="col-sm-6">
                                    <textarea name="content" id="content" cols="30" rows="10" class="">{$artInfo.content}</textarea>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-offset-2 col-sm-6">
                                    <input type="submit" id="articleAdd" class="btn btn-primary" value="修改" />
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- /Page Body -->
</div>
<!-- /Page Content -->
{/block}
{block name="js"}
<script src="__ADMIN__/../lib/ueditor/ueditor.config.js"></script>
<script src="__ADMIN__/../lib/ueditor/ueditor.all.js"></script>
<script>
    UE.getEditor('content');
    $('#articleAdd').click(function () {
        $.ajax({
            url: "{:url('admin/article/edit')}",
            type: "post",
            data: $('form').serialize(),
            dataType: "json",
            success: function (data) {
                if (data.code == 1) {
                    layer.msg(data.msg, {
                        icon: 6,
                        time: 2000
                    }, function () {
                        location.href = data.url
                    })
                } else {
                    layer.open({
                        title: "操作失败",
                        icon: 5,
                        content: data.msg
                    })
                }
            }
        })
        return false;
    });
</script>
{/block}
